/*
 * Copyright (c) 2003, 2004 Ulrich Hilger, http://dev.uhilger.de, all rights reserved.
 *
 * Published under the terms and conditions of the Apache License 2.0,
 * see http://www.apache.org/licenses/LICENSE-2.0
 */

package de.uhilger.app.action;

import javax.swing.AbstractAction;
import java.awt.event.*;
import de.uhilger.app.Application;
import java.util.logging.Level;
import javax.swing.KeyStroke;

/**
 * Class to exit an application
 *
 * @author Ulrich Hilger, <a href="http://dev.uhilger.de" target="_blank">http://dev.uhilger.de</a>
 * @author Published under the terms and conditions of
 * the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License 2.0</a>
 *
 * @version 2, February 12, 2004
 */

public class ExitAction extends AbstractAction {

  /**
   * constructor
   */
  public ExitAction(Application app) {
    super();
    this.app = app;
    putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK));
  }

  /**
   * log termination of this application and exit
   *
   * @param e ActionEvent
   */
  public void actionPerformed(ActionEvent e) {
    Application.log("actionPerformed", getClass(), Level.FINEST);
    app.exitApplication();
  }

  private Application app;

}
